package com.hz.ruoyifarmbase.baseinfo.service.impl;

import com.hz.ruoyifarmbase.baseinfo.domain.AgrBasePlots;
import com.hz.ruoyifarmbase.baseinfo.mapper.AgrBasePlotsMapper;
import com.hz.ruoyifarmbase.baseinfo.service.IAgrBasePlotsService;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 地块Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-05
 */
@Service
public class AgrBasePlotsServiceImpl implements IAgrBasePlotsService
{
    @Autowired
    private AgrBasePlotsMapper agrBasePlotsMapper;

    /**
     * 查询地块
     *
     * @param plotsId 地块主键
     * @return 地块
     */
    @Override
    public AgrBasePlots selectAgrBasePlotsByPlotsId(Long plotsId)
    {
        return agrBasePlotsMapper.selectAgrBasePlotsByPlotsId(plotsId);
    }

    /**
     * 查询地块列表
     *
     * @param agrBasePlots 地块
     * @return 地块
     */
    @Override
    public List<AgrBasePlots> selectAgrBasePlotsList(AgrBasePlots agrBasePlots)
    {
        return agrBasePlotsMapper.selectAgrBasePlotsList(agrBasePlots);
    }

    /**
     * 新增地块
     *
     * @param agrBasePlots 地块
     * @return 结果
     */
    @Override
    public int insertAgrBasePlots(AgrBasePlots agrBasePlots)
    {
        agrBasePlots.setCreateTime(DateUtils.getNowDate());
        return agrBasePlotsMapper.insertAgrBasePlots(agrBasePlots);
    }

    /**
     * 修改地块
     *
     * @param agrBasePlots 地块
     * @return 结果
     */
    @Override
    public int updateAgrBasePlots(AgrBasePlots agrBasePlots)
    {
        System.out.println("BBBBBB++++++++");
        System.out.println(agrBasePlots.toString());
        agrBasePlots.setUpdateTime(DateUtils.getNowDate());
        return agrBasePlotsMapper.updateAgrBasePlots(agrBasePlots);
    }

    /**
     * 批量删除地块
     *
     * @param plotsIds 需要删除的地块主键
     * @return 结果
     */
    @Override
    public int deleteAgrBasePlotsByPlotsIds(Long[] plotsIds)
    {
        return agrBasePlotsMapper.deleteAgrBasePlotsByPlotsIds(plotsIds);
    }

    /**
     * 删除地块信息
     *
     * @param plotsId 地块主键
     * @return 结果
     */
    @Override
    public int deleteAgrBasePlotsByPlotsId(Long plotsId)
    {
        return agrBasePlotsMapper.deleteAgrBasePlotsByPlotsId(plotsId);
    }
}
